package com.xuexiang.xqrcode.decoding;

import android.os.Handler;
import android.os.Looper;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
import com.google.zxing.ResultPointCallback;
import com.xuexiang.xqrcode.ui.ICaptureView;
import java.util.Hashtable;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public final class DecodeThread extends Thread {
    public static final String BARCODE_BITMAP = "barcode_bitmap";
    private final ICaptureView mCaptureView;
    private Handler mHandler;
    private final CountDownLatch mHandlerInitLatch = new CountDownLatch(1);
    private final Hashtable<DecodeHintType, Object> mHints = new Hashtable<>(3);

    /* JADX INFO: Access modifiers changed from: package-private */
    public DecodeThread(ICaptureView iCaptureView, Vector<BarcodeFormat> vector, String str, ResultPointCallback resultPointCallback) {
        this.mCaptureView = iCaptureView;
        if (vector == null || vector.isEmpty()) {
            vector = new Vector<>();
            vector.addAll(DecodeFormatManager.ONE_D_FORMATS);
            vector.addAll(DecodeFormatManager.QR_CODE_FORMATS);
            vector.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
        }
        this.mHints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
        if (str != null) {
            this.mHints.put(DecodeHintType.CHARACTER_SET, str);
        }
        this.mHints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Handler getHandler() {
        try {
            this.mHandlerInitLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return this.mHandler;
    }

    @Override // java.lang.Thread, java.lang.Runnable
    public void run() {
        Looper.prepare();
        this.mHandler = new DecodeHandler(this.mCaptureView, this.mHints);
        this.mHandlerInitLatch.countDown();
        Looper.loop();
    }
}
